# fruit.py
import pygame
import random

FRUIT_IMAGES = {
    'star': "images/food_star.png",
    'tank': "images/food_tank.png",
    'gun': "images/food_gun.png",
    'shell': "images/food_shell.png"
}


class Fruit(pygame.sprite.Sprite):
    def __init__(self, x, y, kind=None):
        super().__init__()
        if not kind:
            kind = random.choice(list(FRUIT_IMAGES.keys()))
        self.kind = kind
        self.image = pygame.image.load(FRUIT_IMAGES[kind])
        self.rect = self.image.get_rect(center=(x, y))

    def update(self):
        pass  # 可以添加闪烁动画等效果

    def picked_up(self, player):
        """处理果实被拾取后的逻辑"""
        result = player.upgrade(self.kind)
        return result